package com.icss.train_sys_back.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    /**
     * 订单处理队列
     */
    public static final String ORDER_QUEUE = "train.order.process";

    /**
     * 声明订单队列
     */
    @Bean
    public Queue orderQueue() {
        // 队列持久化
        return new Queue(ORDER_QUEUE, true);
    }

    /**
     * 使用JSON序列化消息内容
     */
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}